﻿//------------------------------------------------------------
// AureFramework
// Developed By Drunk Fish
// GitHub: https://github.com/YYYurz
// Gitee: https://gitee.com/yyyurz
//------------------------------------------------------------

using System;
using AureFramework.ReferencePool;

namespace AureFramework.Entity
{
	/// <summary>
	/// 实体信息类
	/// </summary>
	public sealed partial class EntityModule : AureFrameworkModule, IEntityModule
	{
		private sealed class EntityInfo: IReference
		{
			public int EntityId
			{
				get;
				private set;
			}
			
			public bool IsPreload
			{
				get;
				private set;
			}
			
			public Type EntityLogicType
			{
				get;
				private set;
			}

			public object UserData
			{
				get;
				private set;
			}

			public Action<bool> Callback
			{
				get;
				private set;
			}

			public static EntityInfo Create(int entityId, bool isPreload, Type entityLogicType, object userData, Action<bool> callback)
			{
				var entityInfo = Aure.GetModule<IReferencePoolModule>().Acquire<EntityInfo>();
				entityInfo.EntityId = entityId;
				entityInfo.IsPreload = isPreload;
				entityInfo.EntityLogicType = entityLogicType;
				entityInfo.UserData = userData;
				entityInfo.Callback = callback;

				return entityInfo;
			}
			
			public void Clear()
			{
				IsPreload = default;
				EntityLogicType = default;
				EntityId = default;
				UserData = default;
				Callback = default;
			}
		}	
	}
}